Repository navigation
feat(stats): add animations and refactor stats components - #371
karanpargal wants to merge 4 commits into
Conversation
|
@karanpargal is attempting to deploy a commit to the EigenLabs Team on Vercel. A member of the Team first needs to authorize it. |
ethenotethan
left a comment
There was a problem hiding this comment.
Automated Code Review — Layr-Labs/d-inference#
Verdict: REQUEST_CHANGES
Security — ✅ No issues found
Performance — 5 finding(s) (3 blocking)
- 🟡 [MEDIUM]
console-ui/src/app/stats/page.tsx:2735— Synchronous fetchStats call in onClick handler blocks UI thread- Suggestion: Wrap fetchStats in async handler or add loading state to prevent UI blocking during network request
- 🟡 [MEDIUM]
console-ui/src/app/stats/page.tsx:2758— Synchronous fetchStats call in onClick handler blocks UI thread- Suggestion: Wrap fetchStats in async handler or add loading state to prevent UI blocking during network request
- 🟡 [MEDIUM]
console-ui/src/app/stats/page.tsx:439-1593— Multiple expensive computations repeated on every render without memoization- Suggestion: Use useMemo for expensive calculations like buildModelInventory, activeNetworkPowerWatts, and geography processing that depend on stats/catalogData
- 🔵 [INFO]
console-ui/src/app/stats/page.tsx:1432-1593— Array.slice() creates new arrays on every render for topCities/topRegions- Suggestion: Memoize topCities and topRegions calculations or use array indexing in render instead of creating new arrays
- 🔵 [INFO]
console-ui/src/components/stats/StatsGeographyPanels.tsx:78-133— Math.max calculation repeated for every bucket in render loop- Suggestion: Pre-calculate maxRequests outside the map function or memoize the calculation
Type_diligence — ✅ No issues found
Additive_complexity — 8 finding(s) (1 blocking)
- 🔵 [INFO]
console-ui/src/app/stats/page.tsx:439-488— Removed HeroStat and MiniStat components are dead code- Suggestion: These components were replaced by new modular components but the old code remains. Remove the dead functions to reduce maintenance burden.
- 🔵 [INFO]
console-ui/src/app/stats/page.tsx:786-797— ModelHeaderMetric function is unused after refactor- Suggestion: This helper function appears to be replaced by the new StatsSectionHeader component. Remove if no longer referenced.
- 🔵 [INFO]
console-ui/src/app/stats/page.tsx:1421-1486— FlowMetric and LocationRow components are dead code- Suggestion: These components were replaced by StatsFlowMetric and StatsProviderCapacityTable. Remove the unused functions.
- 🔵 [INFO]
console-ui/src/app/stats/page.tsx:1593-1649— RequestLocationRow component is unused- Suggestion: This component was replaced by StatsRequestGeographyLeaderboard. Remove the dead code.
- 🟡 [MEDIUM]
console-ui/src/components/stats/styles.ts:1-71— Excessive style token abstraction for simple Tailwind classes- Suggestion: Many of these are just single-use Tailwind class bundles. Consider inlining simpler ones and keeping only complex, reused combinations.
- 🔵 [INFO]
console-ui/src/app/stats/page.tsx:4-32— Importing 30+ individual style tokens creates tight coupling- Suggestion: Consider grouping related styles into objects or using fewer, more semantic class names to reduce import complexity.
- 🔵 [INFO]
console-ui/src/components/stats/StatsGeographyPanels.tsx:14-26— RequestLocationBucketView interface duplicates existing types- Suggestion: Check if this duplicates existing location bucket types in the main stats page. Consider sharing a common interface.
- 🔵 [INFO]
console-ui/src/app/globals.css:360-400— Stats-specific animations in global CSS file- Suggestion: Consider moving stats-specific animations to a dedicated stats.css file or component-scoped styles to maintain separation of concerns.
13 finding(s) total, 4 blocking. Verdict: REQUEST_CHANGES.
🤖 Automated review by Centaur · DAR-186
| @@ -2995,27 +2735,31 @@ export default function StatsPage() { | |||
|
|
|||
There was a problem hiding this comment.
🟡 [MEDIUM] ⚡ Synchronous fetchStats call in onClick handler blocks UI thread
💡 Suggestion: Wrap fetchStats in async handler or add loading state to prevent UI blocking during network request
📊 Score: 2×4 = 8 · Category: blocking_io
| @@ -663,13 +636,7 @@ function ModelRow({ | |||
| : "--"; | |||
|
|
|||
| return ( | |||
| <div | |||
| className={`relative overflow-hidden rounded-xl border px-4 py-4 shadow-sm transition-colors ${ | |||
| isLeader | |||
| ? "border-accent-brand/30 bg-[linear-gradient(135deg,var(--accent-brand-dim),var(--bg-secondary)_42%,var(--bg-primary))]" | |||
| : "border-border-dim bg-bg-secondary" | |||
| }`} | |||
| > | |||
| <div className={`${statsModelCard} ${isLeader ? statsModelCardLeader : ""}`}> | |||
| <div className="flex flex-col gap-4 md:flex-row md:items-start md:justify-between"> | |||
| <div className="flex min-w-0 items-start gap-3"> | |||
| <div | |||
| @@ -819,17 +786,6 @@ function ModelPill({ label }: { label: string }) { | |||
| ); | |||
| } | |||
|
|
|||
| function ModelHeaderMetric({ label, value }: { label: string; value: string }) { | |||
| return ( | |||
| <div> | |||
| <p className="text-lg font-mono font-bold text-text-primary">{value}</p> | |||
| <p className="text-[10px] font-mono uppercase tracking-wider text-text-tertiary"> | |||
| {label} | |||
| </p> | |||
| </div> | |||
| ); | |||
| } | |||
|
|
|||
| function ActiveModelsSection({ | |||
| stats, | |||
| catalogData, | |||
| @@ -870,55 +826,49 @@ function ActiveModelsSection({ | |||
| const routableSlots = visibleInventory.reduce((sum, item) => sum + item.routable, 0); | |||
|
|
|||
| return ( | |||
| <section className="rounded-xl border border-border-dim bg-bg-primary p-5 shadow-sm"> | |||
| <div className="flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between"> | |||
| <div className="flex items-start gap-3"> | |||
| <div className="flex h-9 w-9 items-center justify-center rounded-lg border border-accent-brand/20 bg-accent-brand/10 text-accent-brand"> | |||
| <Layers size={17} /> | |||
| </div> | |||
| <div> | |||
| <h3 className="text-sm font-semibold text-text-primary"> | |||
| Active Models | |||
| </h3> | |||
| <p className="mt-1 text-xs text-text-tertiary"> | |||
| Catalog metadata, live capacity, and trusted node coverage | |||
| </p> | |||
| </div> | |||
| </div> | |||
| <div className="flex flex-col items-start gap-3 sm:items-end"> | |||
| {filtered.deprecatedCount > 0 && ( | |||
| <label className="flex cursor-pointer items-center gap-2 rounded-lg border border-border-dim bg-bg-secondary px-3 py-2 text-xs font-mono text-text-secondary transition-colors hover:bg-bg-hover"> | |||
| <input | |||
| type="checkbox" | |||
| className="sr-only" | |||
| checked={showDeprecatedModels} | |||
| onChange={(event) => setShowDeprecatedModels(event.target.checked)} | |||
| aria-label="Show deprecated models" | |||
| /> | |||
| <section className={`${statsPanel} space-y-5 p-5 sm:p-6 ${statsReveal6}`}> | |||
| <StatsSectionHeader | |||
| index="08" | |||
| title="Active Models" | |||
| description="Catalog metadata, live capacity, and trusted node coverage" | |||
| icon={<Layers size={16} />} | |||
| metrics={[ | |||
| { value: visibleInventory.length.toString(), label: "Models" }, | |||
| { value: totalSlots.toString(), label: "Slots" }, | |||
| { value: routableSlots.toString(), label: "Routable slots" }, | |||
| ]} | |||
| /> | |||
|
|
|||
| {filtered.deprecatedCount > 0 && ( | |||
| <div className="flex justify-end"> | |||
| <label className="flex cursor-pointer items-center gap-2 rounded-[0.35rem] border border-border-dim bg-bg-secondary px-3 py-2 transition-colors hover:border-accent-brand/25 hover:bg-bg-hover"> | |||
| <input | |||
| type="checkbox" | |||
| className="sr-only" | |||
| checked={showDeprecatedModels} | |||
| onChange={(event) => setShowDeprecatedModels(event.target.checked)} | |||
| aria-label="Show deprecated models" | |||
| /> | |||
| <span | |||
| className={`relative h-5 w-9 rounded-full transition-colors ${ | |||
| showDeprecatedModels ? "bg-accent-brand" : "bg-bg-elevated" | |||
| }`} | |||
| aria-hidden="true" | |||
| > | |||
| <span | |||
| className={`relative h-5 w-9 rounded-full transition-colors ${ | |||
| showDeprecatedModels ? "bg-accent-brand" : "bg-bg-elevated" | |||
| className={`absolute top-0.5 h-4 w-4 rounded-full bg-bg-primary shadow-sm transition-transform ${ | |||
| showDeprecatedModels ? "translate-x-4" : "translate-x-0.5" | |||
| }`} | |||
| aria-hidden="true" | |||
| > | |||
| <span | |||
| className={`absolute top-0.5 h-4 w-4 rounded-full bg-bg-primary shadow-sm transition-transform ${ | |||
| showDeprecatedModels ? "translate-x-4" : "translate-x-0.5" | |||
| }`} | |||
| /> | |||
| </span> | |||
| <span>Show deprecated ({filtered.deprecatedCount})</span> | |||
| </label> | |||
| )} | |||
| <div className="grid grid-cols-3 gap-2 text-right sm:min-w-[250px]"> | |||
| <ModelHeaderMetric label="Models" value={visibleInventory.length.toString()} /> | |||
| <ModelHeaderMetric label="Slots" value={totalSlots.toString()} /> | |||
| <ModelHeaderMetric label="Routable Slots" value={routableSlots.toString()} /> | |||
| </div> | |||
| /> | |||
| </span> | |||
| <span className="text-xs font-mono text-text-secondary"> | |||
| Show deprecated ({filtered.deprecatedCount}) | |||
| </span> | |||
| </label> | |||
| </div> | |||
| </div> | |||
| )} | |||
|
|
|||
| <div className="mt-4 grid grid-cols-1 gap-3 lg:grid-cols-[1.2fr_0.8fr]"> | |||
| <div className="grid grid-cols-1 gap-3 lg:grid-cols-[1.2fr_0.8fr]"> | |||
| <div className="space-y-3"> | |||
| {visibleInventory.length === 0 ? ( | |||
| <div className="rounded-xl border border-dashed border-border-dim bg-bg-secondary px-4 py-5 text-sm text-text-tertiary"> | |||
| @@ -935,9 +885,9 @@ function ActiveModelsSection({ | |||
| )) | |||
| )} | |||
| </div> | |||
| <div className="rounded-xl border border-border-dim bg-bg-secondary p-4"> | |||
| <div className="rounded-[0.35rem] border border-border-dim bg-bg-secondary p-5 shadow-sm"> | |||
| <div className="flex items-center justify-between gap-3"> | |||
| <p className="text-xs font-mono uppercase tracking-wider text-text-tertiary"> | |||
| <p className="font-mono text-[0.58rem] tracking-[0.18em] uppercase text-text-tertiary"> | |||
| Fleet Mix | |||
| </p> | |||
| <p className="text-xs font-mono text-text-tertiary"> | |||
| @@ -970,7 +920,7 @@ function ActiveModelsSection({ | |||
| )) | |||
| )} | |||
| </div> | |||
| <div className="mt-5 rounded-lg border border-accent-green/20 bg-accent-green/10 px-3 py-2"> | |||
| <div className="mt-5 rounded border border-accent-green/30 bg-accent-green-dim px-3 py-2.5"> | |||
| <div className="flex items-center justify-between gap-3"> | |||
| <span className="text-xs font-mono text-accent-green">Routable coverage</span> | |||
| <span className="text-sm font-mono font-bold text-accent-green"> | |||
| @@ -1190,57 +1140,22 @@ function ProviderGeography({ stats }: { stats: PlatformStats }) { | |||
| : "No resolved provider locations yet"; | |||
|
|
|||
| return ( | |||
| <section className="bg-bg-primary rounded-xl p-5 sm:p-6 shadow-sm space-y-5"> | |||
| <div className="flex flex-col sm:flex-row sm:items-start sm:justify-between gap-3"> | |||
| <div> | |||
| <div className="flex items-center gap-2"> | |||
| <Globe2 size={16} className="text-accent-brand" /> | |||
| <h2 className="text-sm font-semibold text-text-primary"> | |||
| Live Network Flow | |||
| </h2> | |||
| </div> | |||
| <p className="text-xs text-text-tertiary mt-1"> | |||
| Privacy-bucketed consumer demand flowing into online provider capacity | |||
| </p> | |||
| </div> | |||
| <div className="grid grid-cols-3 gap-2 text-right sm:min-w-[260px]"> | |||
| <div> | |||
| <p className="text-lg font-mono font-bold text-text-primary"> | |||
| {knownProviders} | |||
| </p> | |||
| <p className="text-[10px] font-mono text-text-tertiary uppercase tracking-wider"> | |||
| Providers | |||
| </p> | |||
| </div> | |||
| <div> | |||
| <p className="text-lg font-mono font-bold text-text-primary"> | |||
| {formatNumber(demandOnlyRequests)} | |||
| </p> | |||
| <p className="text-[10px] font-mono text-text-tertiary uppercase tracking-wider"> | |||
| Demand-Only | |||
| </p> | |||
| </div> | |||
| <div> | |||
| <p className="text-lg font-mono font-bold text-text-primary"> | |||
| {requestFlows.length} | |||
| </p> | |||
| <p className="text-[10px] font-mono text-text-tertiary uppercase tracking-wider"> | |||
| Routes | |||
| </p> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| <section className={`${statsPanel} space-y-5 p-5 sm:p-6 ${statsReveal5}`}> | |||
| <StatsSectionHeader | |||
| index="06" | |||
| title="Live Network Flow" | |||
| description="Privacy-bucketed consumer demand flowing into online provider capacity" | |||
| icon={<Globe2 size={16} />} | |||
| metrics={[ | |||
| { value: knownProviders.toString(), label: "Providers" }, | |||
| { value: formatNumber(demandOnlyRequests), label: "Demand-only" }, | |||
| { value: requestFlows.length.toString(), label: "Routes" }, | |||
| ]} | |||
| /> | |||
|
|
|||
| <div className="grid grid-cols-1 items-start gap-5 lg:grid-cols-[minmax(0,1fr)_340px]"> | |||
| <div | |||
| className="relative aspect-[2/1] min-h-[260px] overflow-hidden rounded-xl border border-border-dim bg-bg-secondary shadow-inner" | |||
| style={{ | |||
| background: | |||
| "linear-gradient(180deg, color-mix(in srgb, var(--bg-primary) 64%, transparent), transparent 42%), radial-gradient(ellipse at 50% 36%, color-mix(in srgb, var(--accent-brand) 11%, transparent), transparent 44%), radial-gradient(ellipse at 18% 56%, color-mix(in srgb, var(--accent-green) 9%, transparent), transparent 34%), var(--bg-secondary)", | |||
| boxShadow: | |||
| "inset 0 1px 0 color-mix(in srgb, white 55%, transparent), inset 0 -30px 60px color-mix(in srgb, var(--text-primary) 5%, transparent)", | |||
| }} | |||
| > | |||
| <div | |||
| className={`relative aspect-[2/1] min-h-[260px] overflow-hidden ${statsMapStageFlow} ${statsMapTheaterCorners}`} | |||
| > | |||
| <div className="absolute inset-0 opacity-[0.18]"> | |||
| <div | |||
| className="absolute inset-0" | |||
| @@ -1385,7 +1300,7 @@ function ProviderGeography({ stats }: { stats: PlatformStats }) { | |||
| </g> | |||
| </svg> | |||
|
|
|||
| <div className="pointer-events-none absolute left-4 top-4 z-30 flex flex-wrap items-center gap-2 rounded-lg border border-border-dim bg-bg-primary/90 px-3 py-2 shadow-sm backdrop-blur"> | |||
| <div className={`${statsMapLegend} pointer-events-none absolute left-4 top-4 z-30 flex flex-wrap items-center gap-2`}> | |||
| <span className="flex items-center gap-1.5 text-[11px] font-mono text-text-tertiary"> | |||
| <span className="h-2.5 w-2.5 rounded-full bg-accent-green" /> | |||
| consumers | |||
| @@ -1470,37 +1385,29 @@ function ProviderGeography({ stats }: { stats: PlatformStats }) { | |||
| )} | |||
| </div> | |||
|
|
|||
| <div className="space-y-4"> | |||
| <div className="grid grid-cols-2 gap-3"> | |||
| <FlowMetric label="30m requests" value={formatNumber(recentRequests)} sub={`${formatNumber(peakRequests)} peak/min`} /> | |||
| <FlowMetric label="30m tokens" value={formatNumber(recentTokens)} sub={`${formatNumber(Math.round(recentTokens / recentBuckets.length))}/min avg`} /> | |||
| <FlowMetric label="Routable nodes" value={routableProviders.toString()} sub={`${hardwareProviders} hardware-trusted`} /> | |||
| <FlowMetric | |||
| label="Model TPS" | |||
| value={networkTPS > 0 ? formatNumber(Math.round(networkTPS)) : "--"} | |||
| sub={networkTPS > 0 ? "reported capacity" : "benchmarks pending"} | |||
| /> | |||
| <FlowMetric label="Certificates" value={certificateProviders.toString()} sub="public proof ready" /> | |||
| <FlowMetric label="Remote demand" value={formatNumber(demandOnlyRequests)} sub={`${requestFlows.length} active routes`} /> | |||
| </div> | |||
| <div className="grid grid-cols-2 overflow-hidden rounded-[0.35rem] border border-border-dim bg-bg-secondary shadow-sm md:grid-cols-3 lg:grid-cols-6 divide-x divide-y divide-border-dim lg:divide-y-0"> | |||
| <StatsFlowMetric label="30m requests" value={formatNumber(recentRequests)} sub={`${formatNumber(peakRequests)} peak/min`} /> | |||
| <StatsFlowMetric label="30m tokens" value={formatNumber(recentTokens)} sub={`${formatNumber(Math.round(recentTokens / recentBuckets.length))}/min avg`} /> | |||
| <StatsFlowMetric label="Routable nodes" value={routableProviders.toString()} sub={`${hardwareProviders} hardware-trusted`} /> | |||
| <StatsFlowMetric | |||
| label="Model TPS" | |||
| value={networkTPS > 0 ? formatNumber(Math.round(networkTPS)) : "--"} | |||
| sub={networkTPS > 0 ? "reported capacity" : "benchmarks pending"} | |||
| /> | |||
| <StatsFlowMetric label="Certificates" value={certificateProviders.toString()} sub="public proof ready" /> | |||
| <StatsFlowMetric label="Remote demand" value={formatNumber(demandOnlyRequests)} sub={`${requestFlows.length} active routes`} /> | |||
| </div> | |||
|
|
|||
| <div> | |||
| <h3 className="text-xs font-mono text-text-tertiary uppercase tracking-wider mb-3"> | |||
| Provider Capacity | |||
| </h3> | |||
| <div className="space-y-3"> | |||
| {topCities.length === 0 ? ( | |||
| <p className="text-sm text-text-tertiary"> | |||
| City buckets need at least {privacyMin} providers. | |||
| </p> | |||
| ) : ( | |||
| topCities.map((bucket) => ( | |||
| <LocationRow key={bucket.key} bucket={bucket} compact /> | |||
| )) | |||
| )} | |||
| </div> | |||
| </div> | |||
| </div> | |||
| <div> | |||
| <h3 className="mb-2.5 font-mono text-[0.58rem] tracking-[0.18em] uppercase text-text-tertiary"> | |||
| Provider capacity by region | |||
| </h3> | |||
| <StatsProviderCapacityTable | |||
| buckets={topCities} | |||
| formatPlace={formatPlace} | |||
| formatNumber={formatNumber} | |||
| emptyMessage={`City buckets need at least ${privacyMin} providers.`} | |||
| /> | |||
| </div> | |||
|
|
|||
| {(unknown > 0 || suppressed > 0) && ( | |||
| @@ -1514,71 +1421,6 @@ function ProviderGeography({ stats }: { stats: PlatformStats }) { | |||
| ); | |||
| } | |||
|
|
|||
| function FlowMetric({ | |||
| label, | |||
| value, | |||
| sub, | |||
| }: { | |||
| label: string; | |||
| value: string; | |||
| sub: string; | |||
| }) { | |||
| return ( | |||
| <div className="rounded-lg border border-border-dim bg-bg-secondary px-3 py-2.5"> | |||
| <p className="text-[10px] font-mono uppercase tracking-wider text-text-tertiary"> | |||
| {label} | |||
| </p> | |||
| <p className="mt-1 text-lg font-mono font-bold text-text-primary">{value}</p> | |||
| <p className="mt-0.5 truncate text-[11px] font-mono text-text-tertiary">{sub}</p> | |||
| </div> | |||
| ); | |||
| } | |||
|
|
|||
| function LocationRow({ | |||
| bucket, | |||
| compact, | |||
| }: { | |||
| bucket: ProviderLocationBucket; | |||
| compact?: boolean; | |||
| }) { | |||
| const attestedPct = bucket.providers > 0 | |||
| ? Math.round((bucket.hardware_attested / bucket.providers) * 100) | |||
| : 0; | |||
| const model = bucket.models?.[0]; | |||
|
|
|||
| return ( | |||
| <div className="border-b border-border-dim pb-3 last:border-b-0 last:pb-0"> | |||
| <div className="flex items-start justify-between gap-3"> | |||
| <div className="min-w-0"> | |||
| <p className="text-sm font-semibold text-text-primary truncate"> | |||
| {formatPlace(bucket)} | |||
| </p> | |||
| {!compact && model && ( | |||
| <p className="text-xs font-mono text-text-tertiary truncate mt-0.5"> | |||
| {shortModelName(model)} | |||
| </p> | |||
| )} | |||
| </div> | |||
| <div className="text-right shrink-0"> | |||
| <p className="text-sm font-mono font-bold text-text-primary"> | |||
| {bucket.providers} | |||
| </p> | |||
| <p className="text-[10px] font-mono text-text-tertiary uppercase tracking-wider"> | |||
| nodes | |||
| </p> | |||
| </div> | |||
| </div> | |||
| <div className="mt-2 flex items-center gap-2 text-[11px] font-mono text-text-tertiary"> | |||
| <span>{attestedPct}% attested</span> | |||
| <span className="text-border-subtle">/</span> | |||
| <span>{bucket.gpu_cores} GPU</span> | |||
| <span className="text-border-subtle">/</span> | |||
| <span>{formatNumber(bucket.memory_gb)} GB RAM</span> | |||
| </div> | |||
| </div> | |||
| ); | |||
| } | |||
|
|
|||
| function RequestGeography({ stats }: { stats: PlatformStats }) { | |||
| const cityBuckets = stats.request_locations ?? []; | |||
| const regionBuckets = stats.request_regions ?? []; | |||
| @@ -1590,93 +1432,101 @@ function RequestGeography({ stats }: { stats: PlatformStats }) { | |||
| ? plotted | |||
| : regionBuckets.filter(hasCoordinates); | |||
| const totalRequests = regionBuckets.reduce((sum, bucket) => sum + bucket.requests, 0); | |||
| const topCities = cityBuckets.slice(0, 6); | |||
| const topRegions = regionBuckets.slice(0, 6); | |||
| const topCities = cityBuckets.slice(0, 5); | |||
| const topRegions = regionBuckets.slice(0, 5); | |||
| const maxCityRequests = Math.max(...topCities.map((bucket) => bucket.requests), 1); | |||
| const maxRegionRequests = Math.max(...topRegions.map((bucket) => bucket.requests), 1); | |||
|
|
|||
| return ( | |||
| <section className="bg-bg-primary rounded-xl p-5 sm:p-6 shadow-sm space-y-5"> | |||
| <div className="flex flex-col sm:flex-row sm:items-start sm:justify-between gap-3"> | |||
| <div> | |||
| <div className="flex items-center gap-2"> | |||
| <MapPin size={16} className="text-accent-brand" /> | |||
| <h2 className="text-sm font-semibold text-text-primary"> | |||
| Request Geography | |||
| </h2> | |||
| </div> | |||
| <p className="text-xs text-text-tertiary mt-1"> | |||
| Privacy-bucketed demand origins from the last 24 hours | |||
| </p> | |||
| </div> | |||
| <div className="grid grid-cols-3 gap-2 text-right sm:min-w-[260px]"> | |||
| <div> | |||
| <p className="text-lg font-mono font-bold text-text-primary"> | |||
| {formatNumber(totalRequests)} | |||
| </p> | |||
| <p className="text-[10px] font-mono text-text-tertiary uppercase tracking-wider"> | |||
| Requests | |||
| </p> | |||
| </div> | |||
| <div> | |||
| <p className="text-lg font-mono font-bold text-text-primary"> | |||
| {cityBuckets.length} | |||
| </p> | |||
| <p className="text-[10px] font-mono text-text-tertiary uppercase tracking-wider"> | |||
| Cities | |||
| </p> | |||
| </div> | |||
| <div> | |||
| <p className="text-lg font-mono font-bold text-text-primary"> | |||
| {regionBuckets.length} | |||
| </p> | |||
| <p className="text-[10px] font-mono text-text-tertiary uppercase tracking-wider"> | |||
| Regions | |||
| </p> | |||
| </div> | |||
| </div> | |||
| </div> | |||
|
|
|||
| <div className="grid grid-cols-1 lg:grid-cols-[minmax(0,1fr)_320px] gap-5"> | |||
| <div | |||
| className="relative min-h-[300px] overflow-hidden rounded-lg border border-border-dim bg-bg-secondary shadow-inner" | |||
| style={{ | |||
| background: | |||
| "radial-gradient(circle at 50% 42%, color-mix(in srgb, var(--accent-green) 8%, transparent), transparent 46%), var(--bg-secondary)", | |||
| }} | |||
| > | |||
| <div className="absolute inset-0 opacity-[0.16]"> | |||
| <div | |||
| className="absolute inset-0" | |||
| style={{ | |||
| backgroundImage: | |||
| "linear-gradient(to right, var(--border-subtle) 1px, transparent 1px), linear-gradient(to bottom, var(--border-subtle) 1px, transparent 1px)", | |||
| backgroundSize: "72px 72px", | |||
| }} | |||
| /> | |||
| </div> | |||
| <section className={`${statsPanel} ${statsPanelDemand} space-y-5 p-5 sm:p-6 ${statsReveal6}`}> | |||
| <StatsSectionHeader | |||
| index="07" | |||
| title="Request Geography" | |||
| description="Privacy-bucketed demand origins from the last 24 hours" | |||
| icon={<MapPin size={16} />} | |||
| metrics={[ | |||
| { value: formatNumber(totalRequests), label: "Requests" }, | |||
| { value: cityBuckets.length.toString(), label: "Cities" }, | |||
| { value: regionBuckets.length.toString(), label: "Regions" }, | |||
| ]} | |||
| /> | |||
|
|
|||
| <div className="grid grid-cols-1 gap-5 lg:grid-cols-[minmax(0,1fr)_300px] lg:items-stretch"> | |||
| <div className={`relative aspect-[2/1] min-h-[260px] overflow-hidden ${statsMapStageDemand}`}> | |||
| <svg | |||
| className="absolute inset-0 h-full w-full" | |||
| viewBox="0 0 1000 500" | |||
| preserveAspectRatio="none" | |||
| preserveAspectRatio="xMidYMid meet" | |||
| aria-hidden="true" | |||
| > | |||
| <path | |||
| d={WORLD_LAND_PATH} | |||
| fill="color-mix(in srgb, var(--accent-green) 5%, var(--bg-elevated))" | |||
| <defs> | |||
| <filter id="request-dot-lift" x="-80%" y="-80%" width="260%" height="260%"> | |||
| <feDropShadow dx="0" dy="2" stdDeviation="2" floodColor="rgba(0,0,0,0.2)" /> | |||
| </filter> | |||
| <radialGradient id="request-dot-fill" cx="32%" cy="28%" r="78%"> | |||
| <stop offset="0%" stopColor="rgba(255,255,255,0.78)" /> | |||
| <stop offset="38%" stopColor="var(--accent-green)" /> | |||
| <stop offset="100%" stopColor="color-mix(in srgb, black 18%, var(--accent-green))" /> | |||
| </radialGradient> | |||
| </defs> | |||
| <g | |||
| fill="color-mix(in srgb, var(--accent-green) 6%, var(--bg-elevated))" | |||
| stroke="color-mix(in srgb, var(--text-tertiary) 28%, transparent)" | |||
| strokeWidth="0.85" | |||
| strokeWidth="0.75" | |||
| vectorEffect="non-scaling-stroke" | |||
| opacity="0.86" | |||
| /> | |||
| <path | |||
| d="M118 207 C259 170 414 167 557 191 C683 213 789 246 899 236" | |||
| fill="none" | |||
| stroke="var(--accent-green)" | |||
| strokeWidth="1" | |||
| vectorEffect="non-scaling-stroke" | |||
| opacity="0.14" | |||
| /> | |||
| opacity="0.92" | |||
| > | |||
| <path d={WORLD_LAND_PATH} /> | |||
| </g> | |||
| {fallbackPlotted.length > 0 && ( | |||
| <g> | |||
| {fallbackPlotted.map((bucket) => { | |||
| const point = projectedPoint(bucket); | |||
| const size = Math.min(11, 3.2 + Math.sqrt(bucket.requests) / 26); | |||
| return ( | |||
| <g key={bucket.key} transform={`translate(${point.x * 10} ${point.y * 5})`}> | |||
| <circle | |||
| r={size + 7} | |||
| fill="var(--accent-green)" | |||
| opacity="0.1" | |||
| /> | |||
| <circle | |||
| r={size + 4} | |||
| fill="none" | |||
| stroke="var(--accent-green)" | |||
| strokeOpacity="0.22" | |||
| strokeWidth="1.2" | |||
| vectorEffect="non-scaling-stroke" | |||
| /> | |||
| <circle | |||
| r={size} | |||
| fill="url(#request-dot-fill)" | |||
| stroke="var(--bg-primary)" | |||
| strokeWidth="2" | |||
| filter="url(#request-dot-lift)" | |||
| /> | |||
| <circle | |||
| r={Math.max(1.6, size * 0.28)} | |||
| cx={-size * 0.18} | |||
| cy={-size * 0.2} | |||
| fill="rgba(255,255,255,0.52)" | |||
| /> | |||
| </g> | |||
| ); | |||
| })} | |||
| </g> | |||
| )} | |||
| </svg> | |||
|
|
|||
| {fallbackPlotted.length > 0 && ( | |||
| <div className={`${statsMapLegend} ${statsMapLegendDemand} pointer-events-none absolute left-4 top-4 z-30 flex flex-wrap items-center gap-2`}> | |||
| <span className="flex items-center gap-1.5 text-[11px] font-mono text-text-tertiary"> | |||
| <span className="h-2.5 w-2.5 rounded-full bg-accent-green" /> | |||
| demand density | |||
| </span> | |||
| </div> | |||
| )} | |||
|
|
|||
| {fallbackPlotted.length === 0 ? ( | |||
| <div className="absolute inset-0 flex flex-col items-center justify-center gap-3 px-8 text-center"> | |||
| <MapPin size={22} className="text-text-tertiary" /> | |||
| @@ -1692,28 +1542,27 @@ function RequestGeography({ stats }: { stats: PlatformStats }) { | |||
| ) : ( | |||
| fallbackPlotted.map((bucket) => { | |||
| const point = projectedPoint(bucket); | |||
| const size = Math.min(34, 8 + Math.sqrt(bucket.requests) * 4); | |||
| const tooltipBelow = point.y < 36; | |||
| return ( | |||
| <div | |||
| key={bucket.key} | |||
| className="group absolute -translate-x-1/2 -translate-y-1/2" | |||
| key={`${bucket.key}-tip`} | |||
| className="group absolute z-20 -translate-x-1/2 -translate-y-1/2 hover:z-50" | |||
| style={{ left: `${point.x}%`, top: `${point.y}%` }} | |||
| > | |||
| <span | |||
| className="block h-4 w-4 rounded-full opacity-0" | |||
| aria-hidden="true" | |||
| /> | |||
| <div | |||
| className="relative rounded-full border-2 border-bg-primary bg-accent-green shadow-lg shadow-black/10" | |||
| style={{ | |||
| width: `${size}px`, | |||
| height: `${size}px`, | |||
| boxShadow: `0 0 0 ${Math.max(5, Math.round(size / 3))}px color-mix(in srgb, var(--accent-green) 15%, transparent), 0 10px 28px color-mix(in srgb, var(--accent-green) 22%, transparent)`, | |||
| }} | |||
| className={`pointer-events-none absolute left-1/2 z-50 hidden -translate-x-1/2 group-hover:block ${ | |||
| tooltipBelow ? "top-full mt-2" : "bottom-full mb-2" | |||
| }`} | |||
| > | |||
| <span className="absolute inset-[22%] rounded-full bg-white/20" /> | |||
| </div> | |||
| <div className="absolute left-1/2 bottom-full mb-3 hidden -translate-x-1/2 group-hover:block z-20"> | |||
| <div className="min-w-[190px] rounded-lg bg-text-primary px-3 py-2 text-bg-primary shadow-lg"> | |||
| <p className="text-xs font-semibold">{formatPlace(bucket)}</p> | |||
| <p className="text-[11px] font-mono opacity-80 mt-1"> | |||
| {formatNumber(bucket.requests)} requests / {formatNumber(bucket.prompt_tokens + bucket.completion_tokens)} tokens | |||
| {formatNumber(bucket.requests)} requests /{" "} | |||
| {formatNumber(bucket.prompt_tokens + bucket.completion_tokens)} tokens | |||
| </p> | |||
| </div> | |||
| </div> | |||
| @@ -1723,39 +1572,14 @@ function RequestGeography({ stats }: { stats: PlatformStats }) { | |||
| )} | |||
| </div> | |||
|
|
|||
| <div className="space-y-5"> | |||
| <div> | |||
| <h3 className="text-xs font-mono text-text-tertiary uppercase tracking-wider mb-3"> | |||
| Top Origins | |||
| </h3> | |||
| <div className="space-y-3"> | |||
| {topCities.length === 0 ? ( | |||
| <p className="text-sm text-text-tertiary"> | |||
| No city-level demand buckets yet. | |||
| </p> | |||
| ) : ( | |||
| topCities.map((bucket) => ( | |||
| <RequestLocationRow key={bucket.key} bucket={bucket} /> | |||
| )) | |||
| )} | |||
| </div> | |||
| </div> | |||
|
|
|||
| <div> | |||
| <h3 className="text-xs font-mono text-text-tertiary uppercase tracking-wider mb-3"> | |||
| Top Regions | |||
| </h3> | |||
| <div className="space-y-3"> | |||
| {topRegions.length === 0 ? ( | |||
| <p className="text-sm text-text-tertiary">No demand regions resolved yet.</p> | |||
| ) : ( | |||
| topRegions.map((bucket) => ( | |||
| <RequestLocationRow key={bucket.key} bucket={bucket} compact /> | |||
| )) | |||
| )} | |||
| </div> | |||
| </div> | |||
| </div> | |||
| <StatsRequestGeographyLeaderboard | |||
| cityBuckets={topCities} | |||
| regionBuckets={topRegions} | |||
| maxCityRequests={maxCityRequests} | |||
| maxRegionRequests={maxRegionRequests} | |||
| formatPlace={formatPlace} | |||
| formatNumber={formatNumber} | |||
| /> | |||
| </div> | |||
|
|
|||
| {(unknown > 0 || suppressed > 0) && ( | |||
| @@ -1769,57 +1593,6 @@ function RequestGeography({ stats }: { stats: PlatformStats }) { | |||
| ); | |||
There was a problem hiding this comment.
🟡 [MEDIUM] ⚡ Multiple expensive computations repeated on every render without memoization
💡 Suggestion: Use useMemo for expensive calculations like buildModelInventory, activeNetworkPowerWatts, and geography processing that depend on stats/catalogData
📊 Score: 3×3 = 9 · Category: repeated_work
| @@ -1692,28 +1542,27 @@ function RequestGeography({ stats }: { stats: PlatformStats }) { | |||
| ) : ( | |||
| fallbackPlotted.map((bucket) => { | |||
| const point = projectedPoint(bucket); | |||
| const size = Math.min(34, 8 + Math.sqrt(bucket.requests) * 4); | |||
| const tooltipBelow = point.y < 36; | |||
| return ( | |||
| <div | |||
| key={bucket.key} | |||
| className="group absolute -translate-x-1/2 -translate-y-1/2" | |||
| key={`${bucket.key}-tip`} | |||
| className="group absolute z-20 -translate-x-1/2 -translate-y-1/2 hover:z-50" | |||
| style={{ left: `${point.x}%`, top: `${point.y}%` }} | |||
| > | |||
| <span | |||
| className="block h-4 w-4 rounded-full opacity-0" | |||
| aria-hidden="true" | |||
| /> | |||
| <div | |||
| className="relative rounded-full border-2 border-bg-primary bg-accent-green shadow-lg shadow-black/10" | |||
| style={{ | |||
| width: `${size}px`, | |||
| height: `${size}px`, | |||
| boxShadow: `0 0 0 ${Math.max(5, Math.round(size / 3))}px color-mix(in srgb, var(--accent-green) 15%, transparent), 0 10px 28px color-mix(in srgb, var(--accent-green) 22%, transparent)`, | |||
| }} | |||
| className={`pointer-events-none absolute left-1/2 z-50 hidden -translate-x-1/2 group-hover:block ${ | |||
| tooltipBelow ? "top-full mt-2" : "bottom-full mb-2" | |||
| }`} | |||
| > | |||
| <span className="absolute inset-[22%] rounded-full bg-white/20" /> | |||
| </div> | |||
| <div className="absolute left-1/2 bottom-full mb-3 hidden -translate-x-1/2 group-hover:block z-20"> | |||
| <div className="min-w-[190px] rounded-lg bg-text-primary px-3 py-2 text-bg-primary shadow-lg"> | |||
| <p className="text-xs font-semibold">{formatPlace(bucket)}</p> | |||
| <p className="text-[11px] font-mono opacity-80 mt-1"> | |||
| {formatNumber(bucket.requests)} requests / {formatNumber(bucket.prompt_tokens + bucket.completion_tokens)} tokens | |||
| {formatNumber(bucket.requests)} requests /{" "} | |||
| {formatNumber(bucket.prompt_tokens + bucket.completion_tokens)} tokens | |||
| </p> | |||
| </div> | |||
| </div> | |||
| @@ -1723,39 +1572,14 @@ function RequestGeography({ stats }: { stats: PlatformStats }) { | |||
| )} | |||
| </div> | |||
|
|
|||
| <div className="space-y-5"> | |||
| <div> | |||
| <h3 className="text-xs font-mono text-text-tertiary uppercase tracking-wider mb-3"> | |||
| Top Origins | |||
| </h3> | |||
| <div className="space-y-3"> | |||
| {topCities.length === 0 ? ( | |||
| <p className="text-sm text-text-tertiary"> | |||
| No city-level demand buckets yet. | |||
| </p> | |||
| ) : ( | |||
| topCities.map((bucket) => ( | |||
| <RequestLocationRow key={bucket.key} bucket={bucket} /> | |||
| )) | |||
| )} | |||
| </div> | |||
| </div> | |||
|
|
|||
| <div> | |||
| <h3 className="text-xs font-mono text-text-tertiary uppercase tracking-wider mb-3"> | |||
| Top Regions | |||
| </h3> | |||
| <div className="space-y-3"> | |||
| {topRegions.length === 0 ? ( | |||
| <p className="text-sm text-text-tertiary">No demand regions resolved yet.</p> | |||
| ) : ( | |||
| topRegions.map((bucket) => ( | |||
| <RequestLocationRow key={bucket.key} bucket={bucket} compact /> | |||
| )) | |||
| )} | |||
| </div> | |||
| </div> | |||
| </div> | |||
| <StatsRequestGeographyLeaderboard | |||
| cityBuckets={topCities} | |||
| regionBuckets={topRegions} | |||
| maxCityRequests={maxCityRequests} | |||
| maxRegionRequests={maxRegionRequests} | |||
| formatPlace={formatPlace} | |||
| formatNumber={formatNumber} | |||
| /> | |||
| </div> | |||
|
|
|||
| {(unknown > 0 || suppressed > 0) && ( | |||
| @@ -1769,57 +1593,6 @@ function RequestGeography({ stats }: { stats: PlatformStats }) { | |||
| ); | |||
There was a problem hiding this comment.
🔵 [INFO] ⚡ Array.slice() creates new arrays on every render for topCities/topRegions
💡 Suggestion: Memoize topCities and topRegions calculations or use array indexing in render instead of creating new arrays
📊 Score: 2×3 = 6 · Category: inefficient_data_structures
| <p className="px-3.5 py-5 text-[0.82rem] text-text-tertiary">{emptyMessage}</p> | ||
| ) : ( | ||
| <ol className="m-0 list-none flex-1 p-0.5"> | ||
| {buckets.map((bucket, index) => { | ||
| const tokens = bucket.prompt_tokens + bucket.completion_tokens; | ||
| const barPct = maxRequests > 0 | ||
| ? Math.max(6, (bucket.requests / maxRequests) * 100) | ||
| : 0; | ||
| const rankLabel = (index + 1).toString().padStart(2, "0"); | ||
|
|
||
| return ( | ||
| <li | ||
| key={bucket.key} | ||
| className="grid grid-cols-[1.6rem_minmax(0,1fr)] items-start gap-2 border-b border-border-dim px-3.5 py-2 last:border-b-0" | ||
| > | ||
| <span className="pt-0.5 font-mono text-[0.64rem] font-bold tracking-wide text-accent-brand" aria-hidden="true"> | ||
| {rankLabel} | ||
| </span> | ||
| <div className="min-w-0"> | ||
| <div className="flex items-baseline justify-between gap-2.5"> | ||
| <p className="min-w-0 truncate text-[0.8rem] font-semibold text-text-primary" title={formatPlace(bucket)}> | ||
| {formatPlace(bucket)} | ||
| </p> | ||
| <p className="shrink-0 font-mono text-[0.82rem] font-bold tracking-tight text-text-primary whitespace-nowrap"> | ||
| {formatNumber(bucket.requests)} | ||
| <span className="ml-1 text-[0.56rem] font-medium tracking-widest uppercase text-text-tertiary"> | ||
| req | ||
| </span> | ||
| </p> | ||
| </div> | ||
| <div className="mt-1.5 h-0.5 overflow-hidden rounded-full bg-bg-elevated" aria-hidden="true"> | ||
| <span | ||
| className="block h-full rounded-full bg-linear-to-r from-accent-brand to-accent-green transition-[width] duration-500" | ||
| style={{ width: `${barPct}%` }} | ||
| /> | ||
| </div> | ||
| <p className="mt-1 truncate font-mono text-[0.62rem] text-text-secondary"> | ||
| {formatNumber(tokens)} tokens | ||
| <span className="mx-1 text-text-tertiary">·</span> | ||
| {formatNumber(bucket.prompt_tokens)} in | ||
| <span className="mx-1 text-text-tertiary">/</span> | ||
| {formatNumber(bucket.completion_tokens)} out | ||
| {bucket.providers > 0 && ( | ||
| <> | ||
| <span className="mx-1 text-text-tertiary">·</span> | ||
| {bucket.providers} nodes | ||
| </> | ||
| )} | ||
| </p> | ||
| </div> | ||
| </li> | ||
| ); | ||
| })} | ||
| </ol> | ||
| )} | ||
| </div> |
There was a problem hiding this comment.
🔵 [INFO] ⚡ Math.max calculation repeated for every bucket in render loop
💡 Suggestion: Pre-calculate maxRequests outside the map function or memoize the calculation
📊 Score: 2×3 = 6 · Category: repeated_work
| @@ -1869,13 +1642,11 @@ function ActivityChart({ | |||
| } | |||
|
|
|||
| return ( | |||
| <div className="bg-bg-primary rounded-xl p-5 space-y-4 shadow-sm"> | |||
| <div className="flex items-center justify-between"> | |||
| <div className={`${statsChartCard} ${statsReveal4}`}> | |||
| <div className="flex items-center justify-between mb-4"> | |||
| <div> | |||
| <h3 className="text-xs font-mono text-text-tertiary uppercase tracking-wider"> | |||
| {label} | |||
| </h3> | |||
| <p className="text-xs text-text-tertiary mt-1"> | |||
| <h3 className={statsMetricLabel}>{label}</h3> | |||
| <p className="text-xs mt-1 text-text-tertiary"> | |||
There was a problem hiding this comment.
🔵 [INFO] 🧩 RequestLocationRow component is unused
💡 Suggestion: This component was replaced by StatsRequestGeographyLeaderboard. Remove the dead code.
📊 Score: 2×3 = 6 · Category: dead code
| /** Shared Tailwind class bundles for the stats dashboard. */ | ||
|
|
||
| export const statsReveal = "stats-reveal"; | ||
| export const statsReveal1 = "stats-reveal stats-reveal-1"; | ||
| export const statsReveal2 = "stats-reveal stats-reveal-2"; | ||
| export const statsReveal3 = "stats-reveal stats-reveal-3"; | ||
| export const statsReveal4 = "stats-reveal stats-reveal-4"; | ||
| export const statsReveal5 = "stats-reveal stats-reveal-5"; | ||
| export const statsReveal6 = "stats-reveal stats-reveal-6"; | ||
|
|
||
| export const statsPanel = | ||
| "relative rounded-[0.35rem] border border-border-dim bg-bg-primary shadow-sm overflow-hidden"; | ||
|
|
||
| export const statsMetricLabel = | ||
| "font-mono text-[0.58rem] tracking-[0.2em] uppercase text-text-tertiary mb-1.5"; | ||
|
|
||
| export const statsMetricValue = | ||
| "font-mono font-bold tracking-[-0.045em] leading-[0.88] text-text-primary"; | ||
|
|
||
| export const statsMetricSub = "mt-2 font-mono text-[0.68rem] text-text-tertiary"; | ||
|
|
||
| export const statsSectionIndex = | ||
| "shrink-0 font-mono text-[0.68rem] font-bold tracking-wider text-accent-brand pt-0.5 opacity-85"; | ||
|
|
||
| export const statsMapLegend = | ||
| "pointer-events-none absolute left-4 top-4 z-30 flex flex-wrap items-center gap-2 rounded border border-border-dim bg-bg-primary/90 px-3 py-2 shadow-sm backdrop-blur"; | ||
|
|
||
| export const statsChartCard = | ||
| "relative rounded-[0.35rem] border border-border-dim bg-bg-primary p-5 shadow-sm overflow-hidden"; | ||
|
|
||
| export const statsChartCanvas = | ||
| "relative h-44 overflow-hidden rounded border border-border-dim bg-linear-to-b from-accent-brand-dim to-transparent bg-bg-secondary"; | ||
|
|
||
| export const statsTokenBar = | ||
| "rounded-[0.35rem] border border-border-dim bg-bg-primary px-5 py-5 shadow-sm"; | ||
|
|
||
| export const statsCapacityGrid = | ||
| "grid grid-cols-[minmax(0,2.2fr)_repeat(4,minmax(3.25rem,1fr))] items-center gap-2 px-3.5 py-2"; | ||
|
|
||
| export const statsFlowTickerCell = | ||
| "px-3.5 py-3 transition-colors hover:bg-accent-brand-dim/45"; | ||
|
|
||
| export const statsModelCard = | ||
| "relative overflow-hidden rounded-[0.35rem] border border-border-dim bg-bg-secondary px-4 py-4 shadow-sm transition-[border-color,transform,box-shadow] hover:border-accent-brand/30 hover:-translate-y-0.5 hover:shadow-md"; | ||
|
|
||
| export const statsModelCardLeader = | ||
| "border-accent-brand/35 bg-linear-to-br from-accent-brand-dim via-transparent to-bg-secondary"; | ||
|
|
||
| export const statsFilterPill = | ||
| "rounded border border-border-dim bg-bg-secondary px-3 py-1.5 font-mono text-[0.68rem] tracking-wide uppercase text-text-secondary transition-colors hover:border-border-subtle hover:bg-bg-hover hover:text-text-primary"; | ||
|
|
||
| export const statsFilterPillActive = | ||
| "border-accent-brand/35 bg-accent-brand-dim text-accent-brand"; | ||
|
|
||
| export const statsFilterPillTrustActive = | ||
| "border-accent-green/35 bg-accent-green-dim text-accent-green"; | ||
|
|
||
| export const statsMapStageFlow = | ||
| "rounded border border-border-dim bg-bg-secondary shadow-[inset_0_1px_0_color-mix(in_srgb,var(--bg-white)_50%,transparent),inset_0_-24px_48px_color-mix(in_srgb,var(--text-primary)_4%,transparent)] bg-[linear-gradient(180deg,color-mix(in_srgb,var(--bg-primary)_70%,transparent),transparent_40%),radial-gradient(ellipse_at_50%_38%,var(--accent-brand-dim),transparent_50%),radial-gradient(ellipse_at_82%_62%,var(--accent-green-dim),transparent_32%),var(--bg-secondary)]"; | ||
|
|
||
| export const statsMapStageDemand = | ||
| "rounded-[0.35rem] border border-border-dim bg-bg-secondary shadow-[inset_0_1px_0_color-mix(in_srgb,var(--accent-green)_8%,transparent)] bg-[radial-gradient(ellipse_at_50%_42%,var(--accent-green-dim),transparent_55%),var(--bg-secondary)]"; | ||
|
|
||
| export const statsMapTheaterCorners = | ||
| "before:pointer-events-none before:absolute before:top-2.5 before:left-2.5 before:z-40 before:size-5.5 before:border-t-2 before:border-l-2 before:border-accent-brand/35 after:pointer-events-none after:absolute after:right-2.5 after:bottom-2.5 after:z-40 after:size-5.5 after:border-r-2 after:border-b-2 after:border-accent-brand/35"; | ||
|
|
||
| export const statsMapLegendDemand = | ||
| "border-accent-green/25 bg-[color-mix(in_srgb,var(--bg-primary)_88%,var(--accent-green-dim))]"; | ||
|
|
||
| export const statsPanelDemand = | ||
| "bg-[linear-gradient(180deg,color-mix(in_srgb,var(--accent-green-dim)_35%,var(--bg-primary)),var(--bg-primary))]"; |
There was a problem hiding this comment.
🟡 [MEDIUM] 🧩 Excessive style token abstraction for simple Tailwind classes
💡 Suggestion: Many of these are just single-use Tailwind class bundles. Consider inlining simpler ones and keeping only complex, reused combinations.
📊 Score: 3×4 = 12 · Category: over-abstraction
| import { StatsFlowMetric } from "@/components/stats/StatsFlowMetric"; | ||
| import { StatsProviderCapacityTable, StatsRequestGeographyLeaderboard } from "@/components/stats/StatsGeographyPanels"; | ||
| import { StatsHeroBento } from "@/components/stats/StatsHeroBento"; | ||
| import { StatsHardwareStrip } from "@/components/stats/StatsHardwareStrip"; | ||
| import { StatsMasthead } from "@/components/stats/StatsMasthead"; | ||
| import { StatsObservatoryShell } from "@/components/stats/StatsObservatoryShell"; | ||
| import { StatsSectionHeader } from "@/components/stats/StatsSectionHeader"; | ||
| import { | ||
| statsChartCanvas, | ||
| statsChartCard, | ||
| statsFilterPill, | ||
| statsFilterPillActive, | ||
| statsFilterPillTrustActive, | ||
| statsMapLegend, | ||
| statsMapLegendDemand, | ||
| statsMapStageDemand, | ||
| statsMapStageFlow, | ||
| statsMapTheaterCorners, | ||
| statsMetricLabel, | ||
| statsModelCard, | ||
| statsModelCardLeader, | ||
| statsPanel, | ||
| statsPanelDemand, | ||
| statsReveal2, | ||
| statsReveal4, | ||
| statsReveal5, | ||
| statsReveal6, | ||
| statsTokenBar, | ||
| } from "@/components/stats/styles"; |
There was a problem hiding this comment.
🔵 [INFO] 🧩 Importing 30+ individual style tokens creates tight coupling
💡 Suggestion: Consider grouping related styles into objects or using fewer, more semantic class names to reduce import complexity.
📊 Score: 2×3 = 6 · Category: over-abstraction
| prompt_tokens: number; | ||
| completion_tokens: number; | ||
| providers: number; | ||
| } | ||
|
|
||
| interface StatsRequestGeographyLeaderboardProps { | ||
| cityBuckets: RequestLocationBucketView[]; | ||
| regionBuckets: RequestLocationBucketView[]; | ||
| maxCityRequests: number; | ||
| maxRegionRequests: number; | ||
| formatPlace: (bucket: RequestLocationBucketView) => string; | ||
| formatNumber: (n: number) => string; | ||
| } |
There was a problem hiding this comment.
🔵 [INFO] 🧩 RequestLocationBucketView interface duplicates existing types
💡 Suggestion: Check if this duplicates existing location bucket types in the main stats page. Consider sharing a common interface.
📊 Score: 2×2 = 4 · Category: duplicate logic
| @keyframes stats-reveal-keyframes { | ||
| from { | ||
| opacity: 0; | ||
| transform: translateY(20px); | ||
| } | ||
| to { | ||
| opacity: 1; | ||
| transform: translateY(0); | ||
| } | ||
| } | ||
|
|
||
| @keyframes stats-pulse-ring { | ||
| 0%, 100% { | ||
| box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent-green) 40%, transparent); | ||
| } | ||
| 50% { | ||
| box-shadow: 0 0 0 7px color-mix(in srgb, var(--accent-green) 0%, transparent); | ||
| } | ||
| } | ||
|
|
||
| .stats-reveal { | ||
| animation: stats-reveal-keyframes 0.75s cubic-bezier(0.22, 1, 0.36, 1) both; | ||
| } | ||
|
|
||
| .stats-reveal-1 { animation-delay: 0.04s; } | ||
| .stats-reveal-2 { animation-delay: 0.1s; } | ||
| .stats-reveal-3 { animation-delay: 0.16s; } | ||
| .stats-reveal-4 { animation-delay: 0.22s; } | ||
| .stats-reveal-5 { animation-delay: 0.28s; } | ||
| .stats-reveal-6 { animation-delay: 0.34s; } | ||
|
|
||
| .stats-live-dot { | ||
| animation: stats-pulse-ring 2.2s ease-in-out infinite; | ||
| } | ||
|
|
||
| @media (prefers-reduced-motion: reduce) { | ||
| .stats-reveal, | ||
| .stats-live-dot { | ||
| animation: none; | ||
| } | ||
| } |
There was a problem hiding this comment.
🔵 [INFO] 🧩 Stats-specific animations in global CSS file
💡 Suggestion: Consider moving stats-specific animations to a dedicated stats.css file or component-scoped styles to maintain separation of concerns.
📊 Score: 1×2 = 2 · Category: misplaced responsibility
Memoize expensive geography and inventory computations, add async refresh loading state, consolidate page style tokens, and move stats animations to a scoped stylesheet with shared geography types. Co-authored-by: Cursor <cursoragent@cursor.com>
SDK PRs #370, #371, #382 and #377 merged into mlx-swift-lm main with merge commits. This moves the submodule from the PR head 86a5e4c4 to the SDK main merge 747dd09cfd2566e695b2c77a11bc8e0d2fdc0a44, which contains it. The provider PRs #1668, #1669, #1713 and #1722 now carry the same pin, so they no longer conflict on the submodule. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
SDK PRs #370, #371, #382 and #377 merged into mlx-swift-lm main with merge commits. This moves the submodule from the PR head a4583d2a to the SDK main merge 747dd09cfd2566e695b2c77a11bc8e0d2fdc0a44, which contains it. The provider PRs #1668, #1669, #1713 and #1722 now carry the same pin, so they no longer conflict on the submodule. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
SDK PRs #370, #371, #382 and #377 merged into mlx-swift-lm main with merge commits. This moves the submodule from the PR head 63baac23 to the SDK main merge 747dd09cfd2566e695b2c77a11bc8e0d2fdc0a44, which contains it. The provider PRs #1668, #1669, #1713 and #1722 now carry the same pin, so they no longer conflict on the submodule. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
SDK PRs #370, #371, #382 and #377 merged into mlx-swift-lm main with merge commits. This moves the submodule from the PR head ad2ed74b to the SDK main merge 747dd09cfd2566e695b2c77a11bc8e0d2fdc0a44, which contains it. The provider PRs #1668, #1669, #1713 and #1722 now carry the same pin, so they no longer conflict on the submodule. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Summary
Redesigns the
/statsdashboard (“Signal Observatory”) with a clearer editorial layout, differentiated geography sections, and modular React components. Replaces the page-scopedstats.csswith Tailwind utilities + shared class tokens (components/stats/styles.ts), keeping brand colors and moving entrance/live animations intoglobals.cssalongside existing app animation patterns.Linked issue
Closes #
Test plan
cd console-ui && npm run buildcd console-ui && npx eslint src/app/stats/page.tsx src/components/stats/npm run dev→ open/statsand verify Overview tab (hero bento, fleet telemetry, charts, token bar, Live Network Flow, Request Geography, Active Models, Provider Dashboard)/stats?mock=geofor richer geography mock dataComponents touched
Protocol / interface changes
Notes for reviewers
UI / structure
console-ui/src/components/stats/modules: masthead, hero bento, hardware strip, section headers, observatory shell, flow metrics, geography panels (leaderboard + capacity table), sharedstyles.tspreserveAspectRatio="none")stats.css; animations (stats-reveal, live dot pulse) live inglobals.cssNon-goals
Follow-ups (optional)
page.tsxif we want a thinner route fileNeed help on this PR? Tag
/codesmithwith what you need. Autofix is disabled.